import { observer, useLocalObservable } from 'mobx-react'
import styles from './index.module.less'
import Store from './store'
import { useEffect } from 'react'
import { history } from 'umi'
import { SocketContainer } from '@/hooks/useSocket'

export default observer(() => {
    const store = useLocalObservable(() => Store)
    const { send, onMessage, remove } = SocketContainer.useContainer()

    useEffect(() => {
        const test = () => {
            console.log(3333333333)
        }
        send('1', { channel: 'auction-game', role: 'client', user_id: '1', message: '用户1发来消息', params: [] })
        onMessage('type', test)
        return () => {
            remove('type', test)
        }
    }, [])

    return (
        <div
            className={styles.container}
            onClick={() => {
                send('1', { channel: 'auction-game', role: 'client', user_id: '1', message: '用户1发来消息', params: [] })
            }}
        >
            拍卖
        </div>
    )
})
